<?php

class Map extends CI_Model {
	
	public function getClientLatlong($city='', $town='', $brgy ='',$area=''){		 
	   
		$query = $this->db->get_where('Maitai_LocationPoints', array('city'=> $city ));
		
		if($query->num_rows == 0){			
			
			return false; 
		}	

		$r = $query->result_array();
		return $r;
			
	}
	public function putsClientLoc($lat, $lng, $city = " ", $town = " ", $brgy = " ",$area= " " ){
		
		//$this->db->set(array('lat'=> $lat, 'lng'=> $lng ,'city'=> $city, 'town' => $town, 'brgy' => $brgy, 'area'=> $area ));
		$this->db->set(array('lat'=> $lat, 'lng'=> $lng ,'city'=> $city ));
		if( $this->db->insert('Maitai_LocationPoints') ){
		   return true;
		}		
		 
		return false;
	}	
  public function getStoresFromAPI($name="", $address="", $area="")
  {    
   		$this->load->library('Maitaidata', '', 'Mtdata');
   		$stores = $this->Mtdata->getStoreList($name, $address, $area);
   		$status = $stores->status;
   		if($status==0) {
   			// Has return object
   			return $stores->obj;
   		} else {
   			return false;
   		}
   }
  

}